Audio quality is increasingly emphasized in current communication transmission. Therefore, it is required that music quality should be improved as much as possible during coding and decoding while speech quality is ensured. Because a music signal contains very rich information, a code excited linear prediction (CELP) coding mode for traditional speech cannot be used. A transform coding method is generally used to process a music signal in the frequency domain, so as to increase coding quality of the music signal. However, how to efficiently encode information by effectively using a limited number of coding bits effectively becomes a current main research topic of audio coding.
In a current audio coding technology, Fast Fourier Transform (FFT) or modified discrete cosine transform (MDCT) is generally used to transform a time-domain signal into a frequency-domain signal, and then the frequency-domain signal is encoded. During transform coding, frequency-domain coefficients are allocated to different bands, a normalized energy is calculated for each band, and energies of coefficients in each band are normalized; then, bit allocation is performed; and finally, the intra-band coefficients are quantized according to bits allocated to each band, where bit allocation is an extremely critical step. Bit allocation refers to allocating, in a process of quantizing spectral coefficients, bits that are of an audio signal and used to quantize the spectral coefficients to subbands according to a subband feature of a spectrum, that is, allocating coding resources available for the audio signal to the subbands, where the coding resources are generally represented by bits.
Further, a current bit allocation process includes allocating a band to a spectral signal, for example, increasing bandwidth gradually from a low frequency to a high frequency according to a theory of critical band; allocating a band to a spectrum, calculating a normalized energy norm for each subband, and quantizing the normalized energy to obtain a subband normalization factor wnorm; arranging subbands in descending order of values of subband normalization factors wnorm; and performing bit allocation, for example, allocating the number of bits to each subband in an iterative manner according to the value of the subband normalization factor wnorm. The allocating bits in an iterative manner may be further divided into the following steps: step 1: Initialize the number of bits and an iteration factor fac of each subband; step 2: Find out a band corresponding to a greatest subband normalization factor wnorm; step 3: Add a bandwidth value to the number of bits allocated to the band, and subtract the iteration factor fac from the value of the subband normalization factor wnorm; step 4: Iterate step 2 and step 3 until the bit allocation is completed. It can be learned that, in the prior art, a smallest unit of bits during each allocation is a bandwidth value and a smallest number of bits required during quantization is less than the bandwidth value. As a result, this allocation of an integer number of bits is relatively inefficient in a case of a low bit rate, and bits cannot be allocated to many bands while excessive bits are allocated to another band. Because bits are allocated to all bands in a cyclic and iterative manner, subbands with different bandwidth have a same cyclic and iteration parameter, and therefore an allocation result is very random and quantization is relatively discrete and previous and subsequent frames are discontinuous.
It can be learned that, bit allocation greatly affects performance in the case of a low bit rate. During bit allocation, bits are usually allocated to all bands according to a value of a normalized energy of each subband; and in a case of an insufficient bit rate, this allocation is very random and relatively discrete, and produces a phenomenon of discontinuous quantization in the time domain.